<template>
  <div class="app">
    <h1>{{nanoid}}</h1>
    <SchoolVue></SchoolVue>
    <StudentVue></StudentVue>
  </div>

</template>

<script>
import SchoolVue from './components/School.vue'
import StudentVue from './components/Student.vue'
import pubsub from 'pubsub-js'
export default {
  name: 'App',
  data() {
    return {
      nanoid: null
    }
  },
  components: {
    SchoolVue,
    StudentVue
  },
  mounted() {
    //eventName: 订阅的事件名
    //param: 订阅的事件被促发的参数
    pubsub.subscribe('getNanoid',(eventName,param)=>{
      this.nanoid = param
    })
  },
}
</script>
<style lang="less" scoped>
.app {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
</style>
